<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>

</body>
</html>
<script type="text/javascript">
    var uid = {$uid};   // 要发送的用户
    var client_id = {$client_id}; // 当前的用户id
    var say = "{$huida}";
    // console.log(say);
    ws = new WebSocket('ws://127.0.0.1:8282');
    ws.onopen = function(){
        var data = '{"type":"login","to_uid":"'+uid+'","client_id":"'+client_id+'","name":"李雪峰","say":"'+say+'"}';
        console.log('登录成功登录信息为'+data);
        ws.send(data);
    };
    ws.onmessage = function (e) {
        data = eval("("+e.data+")");

        // var data1 =e.data;
        // data2 = typeof data1 === 'string' ? JSON.parse(data1) : data1;
        if (uid == data.client_id){
            console.log(data);
            /*
             a发送给b  a=》client_id = 10   to_uid = 11
             b发送给a  b=》client_id = 11   to_uid = 10
             to_uid = 11 != client_id  不展示
             client_id != to_uid
            * */
        }

    }
</script>
